
package vip.xiaonuo.biz.modular.lancerUserGoods.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.common.pojo.CommonValidList;
import vip.xiaonuo.biz.modular.lancerUserGoods.entity.BizUserGoods;
import vip.xiaonuo.biz.modular.lancerUserGoods.param.BizUserGoodsAddParam;
import vip.xiaonuo.biz.modular.lancerUserGoods.param.BizUserGoodsEditParam;
import vip.xiaonuo.biz.modular.lancerUserGoods.param.BizUserGoodsIdParam;
import vip.xiaonuo.biz.modular.lancerUserGoods.param.BizUserGoodsPageParam;
import vip.xiaonuo.biz.modular.lancerUserGoods.service.BizUserGoodsService;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;

/**
 * 订单控制器
 *
 * @author Lancer
 * @date  2024/03/03 17:11
 */
@Api(tags = "订单控制器")
@ApiSupport(author = "LANCER_TEAM", order = 1)
@RestController
@Validated
public class BizUserGoodsController {

    @Resource
    private BizUserGoodsService bizUserGoodsService;

    /**
     * 获取订单分页
     *
     * @author Lancer
     * @date  2024/03/03 17:11
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("获取订单分页")
    @SaCheckPermission("/biz/admin/lancerUserGoods/page")
    @GetMapping("/biz/admin/lancerUserGoods/page")
    public CommonResult<Page<BizUserGoods>> page(BizUserGoodsPageParam bizUserGoodsPageParam) {
        return CommonResult.data(bizUserGoodsService.page(bizUserGoodsPageParam));
    }

    /**
     * 添加订单
     *
     * @author Lancer
     * @date  2024/03/03 17:11
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation("添加订单")
    @CommonLog("添加订单")
    @SaCheckPermission("/biz/admin/lancerUserGoods/add")
    @PostMapping("/biz/admin/lancerUserGoods/add")
    public CommonResult<String> add(@RequestBody @Valid BizUserGoodsAddParam bizUserGoodsAddParam) {
        bizUserGoodsService.add(bizUserGoodsAddParam);
        return CommonResult.ok();
    }

    /**
     * 编辑订单
     *
     * @author Lancer
     * @date  2024/03/03 17:11
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation("编辑订单")
    @CommonLog("编辑订单")
    @SaCheckPermission("/biz/admin/lancerUserGoods/edit")
    @PostMapping("/biz/admin/lancerUserGoods/edit")
    public CommonResult<String> edit(@RequestBody @Valid BizUserGoodsEditParam bizUserGoodsEditParam) {
        bizUserGoodsService.edit(bizUserGoodsEditParam);
        return CommonResult.ok();
    }

    /**
     * 删除订单
     *
     * @author Lancer
     * @date  2024/03/03 17:11
     */
    @ApiOperationSupport(order = 4)
    @ApiOperation("删除订单")
    @CommonLog("删除订单")
    @SaCheckPermission("/biz/admin/lancerUserGoods/delete")
    @PostMapping("/biz/admin/lancerUserGoods/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                                   CommonValidList<BizUserGoodsIdParam> bizUserGoodsIdParamList) {
        bizUserGoodsService.delete(bizUserGoodsIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取订单详情
     *
     * @author Lancer
     * @date  2024/03/03 17:11
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("获取订单详情")
    @SaCheckPermission("/biz/admin/lancerUserGoods/detail")
    @GetMapping("/biz/admin/lancerUserGoods/detail")
    public CommonResult<BizUserGoods> detail(@Valid BizUserGoodsIdParam bizUserGoodsIdParam) {
        return CommonResult.data(bizUserGoodsService.detail(bizUserGoodsIdParam));
    }
}
